package com.bw.crop.units;

import com.bw.crop.domain.PdfList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.List;

/**
 * @Author: xushuai
 * @name：EmailUtils
 * @Date：2024/3/14 16:32
 */
@Component
public class EmailUtils {
    @Autowired
    private JavaMailSender javaMailSender;

    @Value("${spring.mail.username}")
    private String fromEmail;

    public void sendEmail(String email, List<PdfList> pdfLists) {
        SimpleMailMessage message = new SimpleMailMessage();
        message.setFrom(fromEmail);
        message.setTo(email+"");
        message.setSubject("支付通知");
        message.setText(pdfLists+"");
        message.setSentDate(new Date());
        javaMailSender.send(message);
    }
}
